<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/10/11
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="stateStr" value="启用,禁用"/>
<c:set var="delim" value=","/>
<c:set var="stateCoverArr" value="${fn:split(stateStr, delim)}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>消息节点模块查询</title>
    <link href="../../css/msgBox/nodeModule.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../js/jquery/jquery-1.12.4.min.js"></script>
    <style type="text/css">
        .template-show {
            display: none;
        }
    </style>
    <script type="text/javascript">
        //return true;跳出循环
        //return false;退出循环
        $(document).ready(function () {
            var n;
            var getIndex = function () {
                $(".template-show").each(function () {
                    if ($(this).css("display") == "table-row") {
                        n = $(this).index() - 2;
                        return false;
                    } else {
                        return true;
                    }
                });
            };
            $(".template-list").click(function () {
                var index = $(this).index() - 1;
                getIndex();
                if (n !== undefined) {
                    if (n == index) {
                        $(".template-show").eq(index).hide();
                        n = undefined;
                    } else {
                        $(".template-show").eq(n).hide();
                        $(".template-show").eq(index).show();
                    }
                } else {
                    $(".template-show").eq(index).show();
                }
            });

            var m;
            var metIndex = function () {
                $(".template-item-show").each(function () {
                    if ($(this).css("display") == "table-row") {
                        m = $(this).index() - 6;
                        return false;
                    } else {
                        return true;
                    }
                });
            };
            $(".template-item").click(function () {
                var index = $(this).index() - 1;
                metIndex();
                if (m !== undefined) {
                    if (m == index) {
                        $(".template-item-show").eq(index).hide();
                        m = undefined;
                    } else {
                        $(".template-item-show").eq(m).hide();
                        $(".template-item-show").eq(index).show();
                    }
                } else {
                    $(".template-item-show").eq(index).show();
                }
            });

        });

    </script>
</head>

<body>
<div class="nodeModule">
    <table class="tableModule" cellspacing="0" cellpadding="0">
        <tr class="customTitle">
            <td class="tdWidth">节点名称</td>
            <td class="tdWidth">电子邮件模版</td>
            <td class="tdWidth">短信模板</td>
            <td class="tdWidth">站内信模版</td>
            <td class="tdWidth">电子邮件状态</td>
            <td class="tdWidth">短信状态</td>
            <td class="tdWidth">站内信状态</td>
            <td class="tdWidth">配置启用状态</td>
            <td class="customWidth">操作</td>
        </tr>
        <c:forEach items="${msgBoxList}" var="msgBox">
            <tr class="documentsReview">
                <td class="tdWidth customReview">${msgBox.name}</td>
                <td class="tdWidth customTemplate template-list"><a href="#">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.mailTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.mailTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.mailTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customTemplate template-list"><a href="#">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.smsTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.smsTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.smsTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customTemplate template-list"><a href="#">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.internalMsgTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.internalMsgTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.internalMsgTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customState">${stateCoverArr[msgBox.mailState]}</td>
                <td class="tdWidth customState">${stateCoverArr[msgBox.smsState]}</td>
                <td class="tdWidth customState">${stateCoverArr[msgBox.internalMsgState]}</td>
                <td class="tdWidth customState">${stateCoverArr[msgBox.settingState]}</td>
                <td class="customWidth"><a class="modification"
                                           href="./edit?id=${msgBox.id}">修改</a></td>
            </tr>
            <tr class="template-show">
                <td colspan="9" class="customExpansion">${msgBox.mailTemplate}</td>
            </tr>
            <tr class="template-show">
                <td colspan="9" class="customExpansion">${msgBox.smsTemplate}</td>
            </tr>
            <tr class="template-show">
                <td colspan="9" class="customExpansion">${msgBox.internalMsgTemplate}</td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
